/**
 * Copyright (c) 2013-2022, Alibaba Group Holding Limited;
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * </p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
// Generated by the protocol buffer compiler.  DO NOT EDIT!
// source: TxnStream.proto

package com.aliyun.polardbx.binlog.protocol;

/**
 * Protobuf type {@code com.aliyun.polardbx.binlog.protocol.TxnMessage}
 */
public final class TxnMessage extends
    com.google.protobuf.GeneratedMessageV3 implements
    // @@protoc_insertion_point(message_implements:com.aliyun.polardbx.binlog.protocol.TxnMessage)
    TxnMessageOrBuilder {
private static final long serialVersionUID = 0L;
  // Use TxnMessage.newBuilder() to construct.
  private TxnMessage(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
    super(builder);
  }
  private TxnMessage() {
    type_ = 0;
  }

  @java.lang.Override
  @SuppressWarnings({"unused"})
  protected java.lang.Object newInstance(
      UnusedPrivateParameter unused) {
    return new TxnMessage();
  }

  @java.lang.Override
  public final com.google.protobuf.UnknownFieldSet
  getUnknownFields() {
    return this.unknownFields;
  }
  private TxnMessage(
      com.google.protobuf.CodedInputStream input,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    this();
    if (extensionRegistry == null) {
      throw new java.lang.NullPointerException();
    }
    com.google.protobuf.UnknownFieldSet.Builder unknownFields =
        com.google.protobuf.UnknownFieldSet.newBuilder();
    try {
      boolean done = false;
      while (!done) {
        int tag = input.readTag();
        switch (tag) {
          case 0:
            done = true;
            break;
          case 8: {
            int rawValue = input.readEnum();

            type_ = rawValue;
            break;
          }
          case 18: {
            com.aliyun.polardbx.binlog.protocol.TxnBegin.Builder subBuilder = null;
            if (txnBegin_ != null) {
              subBuilder = txnBegin_.toBuilder();
            }
            txnBegin_ = input.readMessage(com.aliyun.polardbx.binlog.protocol.TxnBegin.parser(), extensionRegistry);
            if (subBuilder != null) {
              subBuilder.mergeFrom(txnBegin_);
              txnBegin_ = subBuilder.buildPartial();
            }

            break;
          }
          case 26: {
            com.aliyun.polardbx.binlog.protocol.TxnData.Builder subBuilder = null;
            if (txnData_ != null) {
              subBuilder = txnData_.toBuilder();
            }
            txnData_ = input.readMessage(com.aliyun.polardbx.binlog.protocol.TxnData.parser(), extensionRegistry);
            if (subBuilder != null) {
              subBuilder.mergeFrom(txnData_);
              txnData_ = subBuilder.buildPartial();
            }

            break;
          }
          case 34: {
            com.aliyun.polardbx.binlog.protocol.TxnEnd.Builder subBuilder = null;
            if (txnEnd_ != null) {
              subBuilder = txnEnd_.toBuilder();
            }
            txnEnd_ = input.readMessage(com.aliyun.polardbx.binlog.protocol.TxnEnd.parser(), extensionRegistry);
            if (subBuilder != null) {
              subBuilder.mergeFrom(txnEnd_);
              txnEnd_ = subBuilder.buildPartial();
            }

            break;
          }
          case 42: {
            com.aliyun.polardbx.binlog.protocol.TxnTag.Builder subBuilder = null;
            if (txnTag_ != null) {
              subBuilder = txnTag_.toBuilder();
            }
            txnTag_ = input.readMessage(com.aliyun.polardbx.binlog.protocol.TxnTag.parser(), extensionRegistry);
            if (subBuilder != null) {
              subBuilder.mergeFrom(txnTag_);
              txnTag_ = subBuilder.buildPartial();
            }

            break;
          }
          default: {
            if (!parseUnknownField(
                input, unknownFields, extensionRegistry, tag)) {
              done = true;
            }
            break;
          }
        }
      }
    } catch (com.google.protobuf.InvalidProtocolBufferException e) {
      throw e.setUnfinishedMessage(this);
    } catch (java.io.IOException e) {
      throw new com.google.protobuf.InvalidProtocolBufferException(
          e).setUnfinishedMessage(this);
    } finally {
      this.unknownFields = unknownFields.build();
      makeExtensionsImmutable();
    }
  }
  public static final com.google.protobuf.Descriptors.Descriptor
      getDescriptor() {
    return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnMessage_descriptor;
  }

  @java.lang.Override
  protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
      internalGetFieldAccessorTable() {
    return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnMessage_fieldAccessorTable
        .ensureFieldAccessorsInitialized(
            com.aliyun.polardbx.binlog.protocol.TxnMessage.class, com.aliyun.polardbx.binlog.protocol.TxnMessage.Builder.class);
  }

  public static final int TYPE_FIELD_NUMBER = 1;
  private int type_;
  /**
   * <code>.com.aliyun.polardbx.binlog.protocol.MessageType type = 1;</code>
   * @return The enum numeric value on the wire for type.
   */
  @java.lang.Override public int getTypeValue() {
    return type_;
  }
  /**
   * <code>.com.aliyun.polardbx.binlog.protocol.MessageType type = 1;</code>
   * @return The type.
   */
  @java.lang.Override public com.aliyun.polardbx.binlog.protocol.MessageType getType() {
    @SuppressWarnings("deprecation")
    com.aliyun.polardbx.binlog.protocol.MessageType result = com.aliyun.polardbx.binlog.protocol.MessageType.valueOf(type_);
    return result == null ? com.aliyun.polardbx.binlog.protocol.MessageType.UNRECOGNIZED : result;
  }

  public static final int TXNBEGIN_FIELD_NUMBER = 2;
  private com.aliyun.polardbx.binlog.protocol.TxnBegin txnBegin_;
  /**
   * <code>.com.aliyun.polardbx.binlog.protocol.TxnBegin txnBegin = 2;</code>
   * @return Whether the txnBegin field is set.
   */
  @java.lang.Override
  public boolean hasTxnBegin() {
    return txnBegin_ != null;
  }
  /**
   * <code>.com.aliyun.polardbx.binlog.protocol.TxnBegin txnBegin = 2;</code>
   * @return The txnBegin.
   */
  @java.lang.Override
  public com.aliyun.polardbx.binlog.protocol.TxnBegin getTxnBegin() {
    return txnBegin_ == null ? com.aliyun.polardbx.binlog.protocol.TxnBegin.getDefaultInstance() : txnBegin_;
  }
  /**
   * <code>.com.aliyun.polardbx.binlog.protocol.TxnBegin txnBegin = 2;</code>
   */
  @java.lang.Override
  public com.aliyun.polardbx.binlog.protocol.TxnBeginOrBuilder getTxnBeginOrBuilder() {
    return getTxnBegin();
  }

  public static final int TXNDATA_FIELD_NUMBER = 3;
  private com.aliyun.polardbx.binlog.protocol.TxnData txnData_;
  /**
   * <code>.com.aliyun.polardbx.binlog.protocol.TxnData txnData = 3;</code>
   * @return Whether the txnData field is set.
   */
  @java.lang.Override
  public boolean hasTxnData() {
    return txnData_ != null;
  }
  /**
   * <code>.com.aliyun.polardbx.binlog.protocol.TxnData txnData = 3;</code>
   * @return The txnData.
   */
  @java.lang.Override
  public com.aliyun.polardbx.binlog.protocol.TxnData getTxnData() {
    return txnData_ == null ? com.aliyun.polardbx.binlog.protocol.TxnData.getDefaultInstance() : txnData_;
  }
  /**
   * <code>.com.aliyun.polardbx.binlog.protocol.TxnData txnData = 3;</code>
   */
  @java.lang.Override
  public com.aliyun.polardbx.binlog.protocol.TxnDataOrBuilder getTxnDataOrBuilder() {
    return getTxnData();
  }

  public static final int TXNEND_FIELD_NUMBER = 4;
  private com.aliyun.polardbx.binlog.protocol.TxnEnd txnEnd_;
  /**
   * <code>.com.aliyun.polardbx.binlog.protocol.TxnEnd txnEnd = 4;</code>
   * @return Whether the txnEnd field is set.
   */
  @java.lang.Override
  public boolean hasTxnEnd() {
    return txnEnd_ != null;
  }
  /**
   * <code>.com.aliyun.polardbx.binlog.protocol.TxnEnd txnEnd = 4;</code>
   * @return The txnEnd.
   */
  @java.lang.Override
  public com.aliyun.polardbx.binlog.protocol.TxnEnd getTxnEnd() {
    return txnEnd_ == null ? com.aliyun.polardbx.binlog.protocol.TxnEnd.getDefaultInstance() : txnEnd_;
  }
  /**
   * <code>.com.aliyun.polardbx.binlog.protocol.TxnEnd txnEnd = 4;</code>
   */
  @java.lang.Override
  public com.aliyun.polardbx.binlog.protocol.TxnEndOrBuilder getTxnEndOrBuilder() {
    return getTxnEnd();
  }

  public static final int TXNTAG_FIELD_NUMBER = 5;
  private com.aliyun.polardbx.binlog.protocol.TxnTag txnTag_;
  /**
   * <code>.com.aliyun.polardbx.binlog.protocol.TxnTag txnTag = 5;</code>
   * @return Whether the txnTag field is set.
   */
  @java.lang.Override
  public boolean hasTxnTag() {
    return txnTag_ != null;
  }
  /**
   * <code>.com.aliyun.polardbx.binlog.protocol.TxnTag txnTag = 5;</code>
   * @return The txnTag.
   */
  @java.lang.Override
  public com.aliyun.polardbx.binlog.protocol.TxnTag getTxnTag() {
    return txnTag_ == null ? com.aliyun.polardbx.binlog.protocol.TxnTag.getDefaultInstance() : txnTag_;
  }
  /**
   * <code>.com.aliyun.polardbx.binlog.protocol.TxnTag txnTag = 5;</code>
   */
  @java.lang.Override
  public com.aliyun.polardbx.binlog.protocol.TxnTagOrBuilder getTxnTagOrBuilder() {
    return getTxnTag();
  }

  private byte memoizedIsInitialized = -1;
  @java.lang.Override
  public final boolean isInitialized() {
    byte isInitialized = memoizedIsInitialized;
    if (isInitialized == 1) return true;
    if (isInitialized == 0) return false;

    memoizedIsInitialized = 1;
    return true;
  }

  @java.lang.Override
  public void writeTo(com.google.protobuf.CodedOutputStream output)
                      throws java.io.IOException {
    if (type_ != com.aliyun.polardbx.binlog.protocol.MessageType.WHOLE.getNumber()) {
      output.writeEnum(1, type_);
    }
    if (txnBegin_ != null) {
      output.writeMessage(2, getTxnBegin());
    }
    if (txnData_ != null) {
      output.writeMessage(3, getTxnData());
    }
    if (txnEnd_ != null) {
      output.writeMessage(4, getTxnEnd());
    }
    if (txnTag_ != null) {
      output.writeMessage(5, getTxnTag());
    }
    unknownFields.writeTo(output);
  }

  @java.lang.Override
  public int getSerializedSize() {
    int size = memoizedSize;
    if (size != -1) return size;

    size = 0;
    if (type_ != com.aliyun.polardbx.binlog.protocol.MessageType.WHOLE.getNumber()) {
      size += com.google.protobuf.CodedOutputStream
        .computeEnumSize(1, type_);
    }
    if (txnBegin_ != null) {
      size += com.google.protobuf.CodedOutputStream
        .computeMessageSize(2, getTxnBegin());
    }
    if (txnData_ != null) {
      size += com.google.protobuf.CodedOutputStream
        .computeMessageSize(3, getTxnData());
    }
    if (txnEnd_ != null) {
      size += com.google.protobuf.CodedOutputStream
        .computeMessageSize(4, getTxnEnd());
    }
    if (txnTag_ != null) {
      size += com.google.protobuf.CodedOutputStream
        .computeMessageSize(5, getTxnTag());
    }
    size += unknownFields.getSerializedSize();
    memoizedSize = size;
    return size;
  }

  @java.lang.Override
  public boolean equals(final java.lang.Object obj) {
    if (obj == this) {
     return true;
    }
    if (!(obj instanceof com.aliyun.polardbx.binlog.protocol.TxnMessage)) {
      return super.equals(obj);
    }
    com.aliyun.polardbx.binlog.protocol.TxnMessage other = (com.aliyun.polardbx.binlog.protocol.TxnMessage) obj;

    if (type_ != other.type_) return false;
    if (hasTxnBegin() != other.hasTxnBegin()) return false;
    if (hasTxnBegin()) {
      if (!getTxnBegin()
          .equals(other.getTxnBegin())) return false;
    }
    if (hasTxnData() != other.hasTxnData()) return false;
    if (hasTxnData()) {
      if (!getTxnData()
          .equals(other.getTxnData())) return false;
    }
    if (hasTxnEnd() != other.hasTxnEnd()) return false;
    if (hasTxnEnd()) {
      if (!getTxnEnd()
          .equals(other.getTxnEnd())) return false;
    }
    if (hasTxnTag() != other.hasTxnTag()) return false;
    if (hasTxnTag()) {
      if (!getTxnTag()
          .equals(other.getTxnTag())) return false;
    }
    if (!unknownFields.equals(other.unknownFields)) return false;
    return true;
  }

  @java.lang.Override
  public int hashCode() {
    if (memoizedHashCode != 0) {
      return memoizedHashCode;
    }
    int hash = 41;
    hash = (19 * hash) + getDescriptor().hashCode();
    hash = (37 * hash) + TYPE_FIELD_NUMBER;
    hash = (53 * hash) + type_;
    if (hasTxnBegin()) {
      hash = (37 * hash) + TXNBEGIN_FIELD_NUMBER;
      hash = (53 * hash) + getTxnBegin().hashCode();
    }
    if (hasTxnData()) {
      hash = (37 * hash) + TXNDATA_FIELD_NUMBER;
      hash = (53 * hash) + getTxnData().hashCode();
    }
    if (hasTxnEnd()) {
      hash = (37 * hash) + TXNEND_FIELD_NUMBER;
      hash = (53 * hash) + getTxnEnd().hashCode();
    }
    if (hasTxnTag()) {
      hash = (37 * hash) + TXNTAG_FIELD_NUMBER;
      hash = (53 * hash) + getTxnTag().hashCode();
    }
    hash = (29 * hash) + unknownFields.hashCode();
    memoizedHashCode = hash;
    return hash;
  }

  public static com.aliyun.polardbx.binlog.protocol.TxnMessage parseFrom(
      java.nio.ByteBuffer data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }
  public static com.aliyun.polardbx.binlog.protocol.TxnMessage parseFrom(
      java.nio.ByteBuffer data,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }
  public static com.aliyun.polardbx.binlog.protocol.TxnMessage parseFrom(
      com.google.protobuf.ByteString data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }
  public static com.aliyun.polardbx.binlog.protocol.TxnMessage parseFrom(
      com.google.protobuf.ByteString data,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }
  public static com.aliyun.polardbx.binlog.protocol.TxnMessage parseFrom(byte[] data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }
  public static com.aliyun.polardbx.binlog.protocol.TxnMessage parseFrom(
      byte[] data,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }
  public static com.aliyun.polardbx.binlog.protocol.TxnMessage parseFrom(java.io.InputStream input)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseWithIOException(PARSER, input);
  }
  public static com.aliyun.polardbx.binlog.protocol.TxnMessage parseFrom(
      java.io.InputStream input,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseWithIOException(PARSER, input, extensionRegistry);
  }
  public static com.aliyun.polardbx.binlog.protocol.TxnMessage parseDelimitedFrom(java.io.InputStream input)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseDelimitedWithIOException(PARSER, input);
  }
  public static com.aliyun.polardbx.binlog.protocol.TxnMessage parseDelimitedFrom(
      java.io.InputStream input,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
  }
  public static com.aliyun.polardbx.binlog.protocol.TxnMessage parseFrom(
      com.google.protobuf.CodedInputStream input)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseWithIOException(PARSER, input);
  }
  public static com.aliyun.polardbx.binlog.protocol.TxnMessage parseFrom(
      com.google.protobuf.CodedInputStream input,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseWithIOException(PARSER, input, extensionRegistry);
  }

  @java.lang.Override
  public Builder newBuilderForType() { return newBuilder(); }
  public static Builder newBuilder() {
    return DEFAULT_INSTANCE.toBuilder();
  }
  public static Builder newBuilder(com.aliyun.polardbx.binlog.protocol.TxnMessage prototype) {
    return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
  }
  @java.lang.Override
  public Builder toBuilder() {
    return this == DEFAULT_INSTANCE
        ? new Builder() : new Builder().mergeFrom(this);
  }

  @java.lang.Override
  protected Builder newBuilderForType(
      com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
    Builder builder = new Builder(parent);
    return builder;
  }
  /**
   * Protobuf type {@code com.aliyun.polardbx.binlog.protocol.TxnMessage}
   */
  public static final class Builder extends
      com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
      // @@protoc_insertion_point(builder_implements:com.aliyun.polardbx.binlog.protocol.TxnMessage)
      com.aliyun.polardbx.binlog.protocol.TxnMessageOrBuilder {
    public static final com.google.protobuf.Descriptors.Descriptor
        getDescriptor() {
      return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnMessage_descriptor;
    }

    @java.lang.Override
    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
        internalGetFieldAccessorTable() {
      return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnMessage_fieldAccessorTable
          .ensureFieldAccessorsInitialized(
              com.aliyun.polardbx.binlog.protocol.TxnMessage.class, com.aliyun.polardbx.binlog.protocol.TxnMessage.Builder.class);
    }

    // Construct using com.aliyun.polardbx.binlog.protocol.TxnMessage.newBuilder()
    private Builder() {
      maybeForceBuilderInitialization();
    }

    private Builder(
        com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
      super(parent);
      maybeForceBuilderInitialization();
    }
    private void maybeForceBuilderInitialization() {
      if (com.google.protobuf.GeneratedMessageV3
              .alwaysUseFieldBuilders) {
      }
    }
    @java.lang.Override
    public Builder clear() {
      super.clear();
      type_ = 0;

      if (txnBeginBuilder_ == null) {
        txnBegin_ = null;
      } else {
        txnBegin_ = null;
        txnBeginBuilder_ = null;
      }
      if (txnDataBuilder_ == null) {
        txnData_ = null;
      } else {
        txnData_ = null;
        txnDataBuilder_ = null;
      }
      if (txnEndBuilder_ == null) {
        txnEnd_ = null;
      } else {
        txnEnd_ = null;
        txnEndBuilder_ = null;
      }
      if (txnTagBuilder_ == null) {
        txnTag_ = null;
      } else {
        txnTag_ = null;
        txnTagBuilder_ = null;
      }
      return this;
    }

    @java.lang.Override
    public com.google.protobuf.Descriptors.Descriptor
        getDescriptorForType() {
      return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnMessage_descriptor;
    }

    @java.lang.Override
    public com.aliyun.polardbx.binlog.protocol.TxnMessage getDefaultInstanceForType() {
      return com.aliyun.polardbx.binlog.protocol.TxnMessage.getDefaultInstance();
    }

    @java.lang.Override
    public com.aliyun.polardbx.binlog.protocol.TxnMessage build() {
      com.aliyun.polardbx.binlog.protocol.TxnMessage result = buildPartial();
      if (!result.isInitialized()) {
        throw newUninitializedMessageException(result);
      }
      return result;
    }

    @java.lang.Override
    public com.aliyun.polardbx.binlog.protocol.TxnMessage buildPartial() {
      com.aliyun.polardbx.binlog.protocol.TxnMessage result = new com.aliyun.polardbx.binlog.protocol.TxnMessage(this);
      result.type_ = type_;
      if (txnBeginBuilder_ == null) {
        result.txnBegin_ = txnBegin_;
      } else {
        result.txnBegin_ = txnBeginBuilder_.build();
      }
      if (txnDataBuilder_ == null) {
        result.txnData_ = txnData_;
      } else {
        result.txnData_ = txnDataBuilder_.build();
      }
      if (txnEndBuilder_ == null) {
        result.txnEnd_ = txnEnd_;
      } else {
        result.txnEnd_ = txnEndBuilder_.build();
      }
      if (txnTagBuilder_ == null) {
        result.txnTag_ = txnTag_;
      } else {
        result.txnTag_ = txnTagBuilder_.build();
      }
      onBuilt();
      return result;
    }

    @java.lang.Override
    public Builder clone() {
      return super.clone();
    }
    @java.lang.Override
    public Builder setField(
        com.google.protobuf.Descriptors.FieldDescriptor field,
        java.lang.Object value) {
      return super.setField(field, value);
    }
    @java.lang.Override
    public Builder clearField(
        com.google.protobuf.Descriptors.FieldDescriptor field) {
      return super.clearField(field);
    }
    @java.lang.Override
    public Builder clearOneof(
        com.google.protobuf.Descriptors.OneofDescriptor oneof) {
      return super.clearOneof(oneof);
    }
    @java.lang.Override
    public Builder setRepeatedField(
        com.google.protobuf.Descriptors.FieldDescriptor field,
        int index, java.lang.Object value) {
      return super.setRepeatedField(field, index, value);
    }
    @java.lang.Override
    public Builder addRepeatedField(
        com.google.protobuf.Descriptors.FieldDescriptor field,
        java.lang.Object value) {
      return super.addRepeatedField(field, value);
    }
    @java.lang.Override
    public Builder mergeFrom(com.google.protobuf.Message other) {
      if (other instanceof com.aliyun.polardbx.binlog.protocol.TxnMessage) {
        return mergeFrom((com.aliyun.polardbx.binlog.protocol.TxnMessage)other);
      } else {
        super.mergeFrom(other);
        return this;
      }
    }

    public Builder mergeFrom(com.aliyun.polardbx.binlog.protocol.TxnMessage other) {
      if (other == com.aliyun.polardbx.binlog.protocol.TxnMessage.getDefaultInstance()) return this;
      if (other.type_ != 0) {
        setTypeValue(other.getTypeValue());
      }
      if (other.hasTxnBegin()) {
        mergeTxnBegin(other.getTxnBegin());
      }
      if (other.hasTxnData()) {
        mergeTxnData(other.getTxnData());
      }
      if (other.hasTxnEnd()) {
        mergeTxnEnd(other.getTxnEnd());
      }
      if (other.hasTxnTag()) {
        mergeTxnTag(other.getTxnTag());
      }
      this.mergeUnknownFields(other.unknownFields);
      onChanged();
      return this;
    }

    @java.lang.Override
    public final boolean isInitialized() {
      return true;
    }

    @java.lang.Override
    public Builder mergeFrom(
        com.google.protobuf.CodedInputStream input,
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
        throws java.io.IOException {
      com.aliyun.polardbx.binlog.protocol.TxnMessage parsedMessage = null;
      try {
        parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
      } catch (com.google.protobuf.InvalidProtocolBufferException e) {
        parsedMessage = (com.aliyun.polardbx.binlog.protocol.TxnMessage) e.getUnfinishedMessage();
        throw e.unwrapIOException();
      } finally {
        if (parsedMessage != null) {
          mergeFrom(parsedMessage);
        }
      }
      return this;
    }

    private int type_ = 0;
    /**
     * <code>.com.aliyun.polardbx.binlog.protocol.MessageType type = 1;</code>
     * @return The enum numeric value on the wire for type.
     */
    @java.lang.Override public int getTypeValue() {
      return type_;
    }
    /**
     * <code>.com.aliyun.polardbx.binlog.protocol.MessageType type = 1;</code>
     * @param value The enum numeric value on the wire for type to set.
     * @return This builder for chaining.
     */
    public Builder setTypeValue(int value) {
      
      type_ = value;
      onChanged();
      return this;
    }
    /**
     * <code>.com.aliyun.polardbx.binlog.protocol.MessageType type = 1;</code>
     * @return The type.
     */
    @java.lang.Override
    public com.aliyun.polardbx.binlog.protocol.MessageType getType() {
      @SuppressWarnings("deprecation")
      com.aliyun.polardbx.binlog.protocol.MessageType result = com.aliyun.polardbx.binlog.protocol.MessageType.valueOf(type_);
      return result == null ? com.aliyun.polardbx.binlog.protocol.MessageType.UNRECOGNIZED : result;
    }
    /**
     * <code>.com.aliyun.polardbx.binlog.protocol.MessageType type = 1;</code>
     * @param value The type to set.
     * @return This builder for chaining.
     */
    public Builder setType(com.aliyun.polardbx.binlog.protocol.MessageType value) {
      if (value == null) {
        throw new NullPointerException();
      }
      
      type_ = value.getNumber();
      onChanged();
      return this;
    }
    /**
     * <code>.com.aliyun.polardbx.binlog.protocol.MessageType type = 1;</code>
     * @return This builder for chaining.
     */
    public Builder clearType() {
      
      type_ = 0;
      onChanged();
      return this;
    }

    private com.aliyun.polardbx.binlog.protocol.TxnBegin txnBegin_;
    private com.google.protobuf.SingleFieldBuilderV3<
        com.aliyun.polardbx.binlog.protocol.TxnBegin, com.aliyun.polardbx.binlog.protocol.TxnBegin.Builder, com.aliyun.polardbx.binlog.protocol.TxnBeginOrBuilder> txnBeginBuilder_;
    /**
     * <code>.com.aliyun.polardbx.binlog.protocol.TxnBegin txnBegin = 2;</code>
     * @return Whether the txnBegin field is set.
     */
    public boolean hasTxnBegin() {
      return txnBeginBuilder_ != null || txnBegin_ != null;
    }
    /**
     * <code>.com.aliyun.polardbx.binlog.protocol.TxnBegin txnBegin = 2;</code>
     * @return The txnBegin.
     */
    public com.aliyun.polardbx.binlog.protocol.TxnBegin getTxnBegin() {
      if (txnBeginBuilder_ == null) {
        return txnBegin_ == null ? com.aliyun.polardbx.binlog.protocol.TxnBegin.getDefaultInstance() : txnBegin_;
      } else {
        return txnBeginBuilder_.getMessage();
      }
    }
    /**
     * <code>.com.aliyun.polardbx.binlog.protocol.TxnBegin txnBegin = 2;</code>
     */
    public Builder setTxnBegin(com.aliyun.polardbx.binlog.protocol.TxnBegin value) {
      if (txnBeginBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        txnBegin_ = value;
        onChanged();
      } else {
        txnBeginBuilder_.setMessage(value);
      }

      return this;
    }
    /**
     * <code>.com.aliyun.polardbx.binlog.protocol.TxnBegin txnBegin = 2;</code>
     */
    public Builder setTxnBegin(
        com.aliyun.polardbx.binlog.protocol.TxnBegin.Builder builderForValue) {
      if (txnBeginBuilder_ == null) {
        txnBegin_ = builderForValue.build();
        onChanged();
      } else {
        txnBeginBuilder_.setMessage(builderForValue.build());
      }

      return this;
    }
    /**
     * <code>.com.aliyun.polardbx.binlog.protocol.TxnBegin txnBegin = 2;</code>
     */
    public Builder mergeTxnBegin(com.aliyun.polardbx.binlog.protocol.TxnBegin value) {
      if (txnBeginBuilder_ == null) {
        if (txnBegin_ != null) {
          txnBegin_ =
            com.aliyun.polardbx.binlog.protocol.TxnBegin.newBuilder(txnBegin_).mergeFrom(value).buildPartial();
        } else {
          txnBegin_ = value;
        }
        onChanged();
      } else {
        txnBeginBuilder_.mergeFrom(value);
      }

      return this;
    }
    /**
     * <code>.com.aliyun.polardbx.binlog.protocol.TxnBegin txnBegin = 2;</code>
     */
    public Builder clearTxnBegin() {
      if (txnBeginBuilder_ == null) {
        txnBegin_ = null;
        onChanged();
      } else {
        txnBegin_ = null;
        txnBeginBuilder_ = null;
      }

      return this;
    }
    /**
     * <code>.com.aliyun.polardbx.binlog.protocol.TxnBegin txnBegin = 2;</code>
     */
    public com.aliyun.polardbx.binlog.protocol.TxnBegin.Builder getTxnBeginBuilder() {
      
      onChanged();
      return getTxnBeginFieldBuilder().getBuilder();
    }
    /**
     * <code>.com.aliyun.polardbx.binlog.protocol.TxnBegin txnBegin = 2;</code>
     */
    public com.aliyun.polardbx.binlog.protocol.TxnBeginOrBuilder getTxnBeginOrBuilder() {
      if (txnBeginBuilder_ != null) {
        return txnBeginBuilder_.getMessageOrBuilder();
      } else {
        return txnBegin_ == null ?
            com.aliyun.polardbx.binlog.protocol.TxnBegin.getDefaultInstance() : txnBegin_;
      }
    }
    /**
     * <code>.com.aliyun.polardbx.binlog.protocol.TxnBegin txnBegin = 2;</code>
     */
    private com.google.protobuf.SingleFieldBuilderV3<
        com.aliyun.polardbx.binlog.protocol.TxnBegin, com.aliyun.polardbx.binlog.protocol.TxnBegin.Builder, com.aliyun.polardbx.binlog.protocol.TxnBeginOrBuilder> 
        getTxnBeginFieldBuilder() {
      if (txnBeginBuilder_ == null) {
        txnBeginBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
            com.aliyun.polardbx.binlog.protocol.TxnBegin, com.aliyun.polardbx.binlog.protocol.TxnBegin.Builder, com.aliyun.polardbx.binlog.protocol.TxnBeginOrBuilder>(
                getTxnBegin(),
                getParentForChildren(),
                isClean());
        txnBegin_ = null;
      }
      return txnBeginBuilder_;
    }

    private com.aliyun.polardbx.binlog.protocol.TxnData txnData_;
    private com.google.protobuf.SingleFieldBuilderV3<
        com.aliyun.polardbx.binlog.protocol.TxnData, com.aliyun.polardbx.binlog.protocol.TxnData.Builder, com.aliyun.polardbx.binlog.protocol.TxnDataOrBuilder> txnDataBuilder_;
    /**
     * <code>.com.aliyun.polardbx.binlog.protocol.TxnData txnData = 3;</code>
     * @return Whether the txnData field is set.
     */
    public boolean hasTxnData() {
      return txnDataBuilder_ != null || txnData_ != null;
    }
    /**
     * <code>.com.aliyun.polardbx.binlog.protocol.TxnData txnData = 3;</code>
     * @return The txnData.
     */
    public com.aliyun.polardbx.binlog.protocol.TxnData getTxnData() {
      if (txnDataBuilder_ == null) {
        return txnData_ == null ? com.aliyun.polardbx.binlog.protocol.TxnData.getDefaultInstance() : txnData_;
      } else {
        return txnDataBuilder_.getMessage();
      }
    }
    /**
     * <code>.com.aliyun.polardbx.binlog.protocol.TxnData txnData = 3;</code>
     */
    public Builder setTxnData(com.aliyun.polardbx.binlog.protocol.TxnData value) {
      if (txnDataBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        txnData_ = value;
        onChanged();
      } else {
        txnDataBuilder_.setMessage(value);
      }

      return this;
    }
    /**
     * <code>.com.aliyun.polardbx.binlog.protocol.TxnData txnData = 3;</code>
     */
    public Builder setTxnData(
        com.aliyun.polardbx.binlog.protocol.TxnData.Builder builderForValue) {
      if (txnDataBuilder_ == null) {
        txnData_ = builderForValue.build();
        onChanged();
      } else {
        txnDataBuilder_.setMessage(builderForValue.build());
      }

      return this;
    }
    /**
     * <code>.com.aliyun.polardbx.binlog.protocol.TxnData txnData = 3;</code>
     */
    public Builder mergeTxnData(com.aliyun.polardbx.binlog.protocol.TxnData value) {
      if (txnDataBuilder_ == null) {
        if (txnData_ != null) {
          txnData_ =
            com.aliyun.polardbx.binlog.protocol.TxnData.newBuilder(txnData_).mergeFrom(value).buildPartial();
        } else {
          txnData_ = value;
        }
        onChanged();
      } else {
        txnDataBuilder_.mergeFrom(value);
      }

      return this;
    }
    /**
     * <code>.com.aliyun.polardbx.binlog.protocol.TxnData txnData = 3;</code>
     */
    public Builder clearTxnData() {
      if (txnDataBuilder_ == null) {
        txnData_ = null;
        onChanged();
      } else {
        txnData_ = null;
        txnDataBuilder_ = null;
      }

      return this;
    }
    /**
     * <code>.com.aliyun.polardbx.binlog.protocol.TxnData txnData = 3;</code>
     */
    public com.aliyun.polardbx.binlog.protocol.TxnData.Builder getTxnDataBuilder() {
      
      onChanged();
      return getTxnDataFieldBuilder().getBuilder();
    }
    /**
     * <code>.com.aliyun.polardbx.binlog.protocol.TxnData txnData = 3;</code>
     */
    public com.aliyun.polardbx.binlog.protocol.TxnDataOrBuilder getTxnDataOrBuilder() {
      if (txnDataBuilder_ != null) {
        return txnDataBuilder_.getMessageOrBuilder();
      } else {
        return txnData_ == null ?
            com.aliyun.polardbx.binlog.protocol.TxnData.getDefaultInstance() : txnData_;
      }
    }
    /**
     * <code>.com.aliyun.polardbx.binlog.protocol.TxnData txnData = 3;</code>
     */
    private com.google.protobuf.SingleFieldBuilderV3<
        com.aliyun.polardbx.binlog.protocol.TxnData, com.aliyun.polardbx.binlog.protocol.TxnData.Builder, com.aliyun.polardbx.binlog.protocol.TxnDataOrBuilder> 
        getTxnDataFieldBuilder() {
      if (txnDataBuilder_ == null) {
        txnDataBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
            com.aliyun.polardbx.binlog.protocol.TxnData, com.aliyun.polardbx.binlog.protocol.TxnData.Builder, com.aliyun.polardbx.binlog.protocol.TxnDataOrBuilder>(
                getTxnData(),
                getParentForChildren(),
                isClean());
        txnData_ = null;
      }
      return txnDataBuilder_;
    }

    private com.aliyun.polardbx.binlog.protocol.TxnEnd txnEnd_;
    private com.google.protobuf.SingleFieldBuilderV3<
        com.aliyun.polardbx.binlog.protocol.TxnEnd, com.aliyun.polardbx.binlog.protocol.TxnEnd.Builder, com.aliyun.polardbx.binlog.protocol.TxnEndOrBuilder> txnEndBuilder_;
    /**
     * <code>.com.aliyun.polardbx.binlog.protocol.TxnEnd txnEnd = 4;</code>
     * @return Whether the txnEnd field is set.
     */
    public boolean hasTxnEnd() {
      return txnEndBuilder_ != null || txnEnd_ != null;
    }
    /**
     * <code>.com.aliyun.polardbx.binlog.protocol.TxnEnd txnEnd = 4;</code>
     * @return The txnEnd.
     */
    public com.aliyun.polardbx.binlog.protocol.TxnEnd getTxnEnd() {
      if (txnEndBuilder_ == null) {
        return txnEnd_ == null ? com.aliyun.polardbx.binlog.protocol.TxnEnd.getDefaultInstance() : txnEnd_;
      } else {
        return txnEndBuilder_.getMessage();
      }
    }
    /**
     * <code>.com.aliyun.polardbx.binlog.protocol.TxnEnd txnEnd = 4;</code>
     */
    public Builder setTxnEnd(com.aliyun.polardbx.binlog.protocol.TxnEnd value) {
      if (txnEndBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        txnEnd_ = value;
        onChanged();
      } else {
        txnEndBuilder_.setMessage(value);
      }

      return this;
    }
    /**
     * <code>.com.aliyun.polardbx.binlog.protocol.TxnEnd txnEnd = 4;</code>
     */
    public Builder setTxnEnd(
        com.aliyun.polardbx.binlog.protocol.TxnEnd.Builder builderForValue) {
      if (txnEndBuilder_ == null) {
        txnEnd_ = builderForValue.build();
        onChanged();
      } else {
        txnEndBuilder_.setMessage(builderForValue.build());
      }

      return this;
    }
    /**
     * <code>.com.aliyun.polardbx.binlog.protocol.TxnEnd txnEnd = 4;</code>
     */
    public Builder mergeTxnEnd(com.aliyun.polardbx.binlog.protocol.TxnEnd value) {
      if (txnEndBuilder_ == null) {
        if (txnEnd_ != null) {
          txnEnd_ =
            com.aliyun.polardbx.binlog.protocol.TxnEnd.newBuilder(txnEnd_).mergeFrom(value).buildPartial();
        } else {
          txnEnd_ = value;
        }
        onChanged();
      } else {
        txnEndBuilder_.mergeFrom(value);
      }

      return this;
    }
    /**
     * <code>.com.aliyun.polardbx.binlog.protocol.TxnEnd txnEnd = 4;</code>
     */
    public Builder clearTxnEnd() {
      if (txnEndBuilder_ == null) {
        txnEnd_ = null;
        onChanged();
      } else {
        txnEnd_ = null;
        txnEndBuilder_ = null;
      }

      return this;
    }
    /**
     * <code>.com.aliyun.polardbx.binlog.protocol.TxnEnd txnEnd = 4;</code>
     */
    public com.aliyun.polardbx.binlog.protocol.TxnEnd.Builder getTxnEndBuilder() {
      
      onChanged();
      return getTxnEndFieldBuilder().getBuilder();
    }
    /**
     * <code>.com.aliyun.polardbx.binlog.protocol.TxnEnd txnEnd = 4;</code>
     */
    public com.aliyun.polardbx.binlog.protocol.TxnEndOrBuilder getTxnEndOrBuilder() {
      if (txnEndBuilder_ != null) {
        return txnEndBuilder_.getMessageOrBuilder();
      } else {
        return txnEnd_ == null ?
            com.aliyun.polardbx.binlog.protocol.TxnEnd.getDefaultInstance() : txnEnd_;
      }
    }
    /**
     * <code>.com.aliyun.polardbx.binlog.protocol.TxnEnd txnEnd = 4;</code>
     */
    private com.google.protobuf.SingleFieldBuilderV3<
        com.aliyun.polardbx.binlog.protocol.TxnEnd, com.aliyun.polardbx.binlog.protocol.TxnEnd.Builder, com.aliyun.polardbx.binlog.protocol.TxnEndOrBuilder> 
        getTxnEndFieldBuilder() {
      if (txnEndBuilder_ == null) {
        txnEndBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
            com.aliyun.polardbx.binlog.protocol.TxnEnd, com.aliyun.polardbx.binlog.protocol.TxnEnd.Builder, com.aliyun.polardbx.binlog.protocol.TxnEndOrBuilder>(
                getTxnEnd(),
                getParentForChildren(),
                isClean());
        txnEnd_ = null;
      }
      return txnEndBuilder_;
    }

    private com.aliyun.polardbx.binlog.protocol.TxnTag txnTag_;
    private com.google.protobuf.SingleFieldBuilderV3<
        com.aliyun.polardbx.binlog.protocol.TxnTag, com.aliyun.polardbx.binlog.protocol.TxnTag.Builder, com.aliyun.polardbx.binlog.protocol.TxnTagOrBuilder> txnTagBuilder_;
    /**
     * <code>.com.aliyun.polardbx.binlog.protocol.TxnTag txnTag = 5;</code>
     * @return Whether the txnTag field is set.
     */
    public boolean hasTxnTag() {
      return txnTagBuilder_ != null || txnTag_ != null;
    }
    /**
     * <code>.com.aliyun.polardbx.binlog.protocol.TxnTag txnTag = 5;</code>
     * @return The txnTag.
     */
    public com.aliyun.polardbx.binlog.protocol.TxnTag getTxnTag() {
      if (txnTagBuilder_ == null) {
        return txnTag_ == null ? com.aliyun.polardbx.binlog.protocol.TxnTag.getDefaultInstance() : txnTag_;
      } else {
        return txnTagBuilder_.getMessage();
      }
    }
    /**
     * <code>.com.aliyun.polardbx.binlog.protocol.TxnTag txnTag = 5;</code>
     */
    public Builder setTxnTag(com.aliyun.polardbx.binlog.protocol.TxnTag value) {
      if (txnTagBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        txnTag_ = value;
        onChanged();
      } else {
        txnTagBuilder_.setMessage(value);
      }

      return this;
    }
    /**
     * <code>.com.aliyun.polardbx.binlog.protocol.TxnTag txnTag = 5;</code>
     */
    public Builder setTxnTag(
        com.aliyun.polardbx.binlog.protocol.TxnTag.Builder builderForValue) {
      if (txnTagBuilder_ == null) {
        txnTag_ = builderForValue.build();
        onChanged();
      } else {
        txnTagBuilder_.setMessage(builderForValue.build());
      }

      return this;
    }
    /**
     * <code>.com.aliyun.polardbx.binlog.protocol.TxnTag txnTag = 5;</code>
     */
    public Builder mergeTxnTag(com.aliyun.polardbx.binlog.protocol.TxnTag value) {
      if (txnTagBuilder_ == null) {
        if (txnTag_ != null) {
          txnTag_ =
            com.aliyun.polardbx.binlog.protocol.TxnTag.newBuilder(txnTag_).mergeFrom(value).buildPartial();
        } else {
          txnTag_ = value;
        }
        onChanged();
      } else {
        txnTagBuilder_.mergeFrom(value);
      }

      return this;
    }
    /**
     * <code>.com.aliyun.polardbx.binlog.protocol.TxnTag txnTag = 5;</code>
     */
    public Builder clearTxnTag() {
      if (txnTagBuilder_ == null) {
        txnTag_ = null;
        onChanged();
      } else {
        txnTag_ = null;
        txnTagBuilder_ = null;
      }

      return this;
    }
    /**
     * <code>.com.aliyun.polardbx.binlog.protocol.TxnTag txnTag = 5;</code>
     */
    public com.aliyun.polardbx.binlog.protocol.TxnTag.Builder getTxnTagBuilder() {
      
      onChanged();
      return getTxnTagFieldBuilder().getBuilder();
    }
    /**
     * <code>.com.aliyun.polardbx.binlog.protocol.TxnTag txnTag = 5;</code>
     */
    public com.aliyun.polardbx.binlog.protocol.TxnTagOrBuilder getTxnTagOrBuilder() {
      if (txnTagBuilder_ != null) {
        return txnTagBuilder_.getMessageOrBuilder();
      } else {
        return txnTag_ == null ?
            com.aliyun.polardbx.binlog.protocol.TxnTag.getDefaultInstance() : txnTag_;
      }
    }
    /**
     * <code>.com.aliyun.polardbx.binlog.protocol.TxnTag txnTag = 5;</code>
     */
    private com.google.protobuf.SingleFieldBuilderV3<
        com.aliyun.polardbx.binlog.protocol.TxnTag, com.aliyun.polardbx.binlog.protocol.TxnTag.Builder, com.aliyun.polardbx.binlog.protocol.TxnTagOrBuilder> 
        getTxnTagFieldBuilder() {
      if (txnTagBuilder_ == null) {
        txnTagBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
            com.aliyun.polardbx.binlog.protocol.TxnTag, com.aliyun.polardbx.binlog.protocol.TxnTag.Builder, com.aliyun.polardbx.binlog.protocol.TxnTagOrBuilder>(
                getTxnTag(),
                getParentForChildren(),
                isClean());
        txnTag_ = null;
      }
      return txnTagBuilder_;
    }
    @java.lang.Override
    public final Builder setUnknownFields(
        final com.google.protobuf.UnknownFieldSet unknownFields) {
      return super.setUnknownFields(unknownFields);
    }

    @java.lang.Override
    public final Builder mergeUnknownFields(
        final com.google.protobuf.UnknownFieldSet unknownFields) {
      return super.mergeUnknownFields(unknownFields);
    }


    // @@protoc_insertion_point(builder_scope:com.aliyun.polardbx.binlog.protocol.TxnMessage)
  }

  // @@protoc_insertion_point(class_scope:com.aliyun.polardbx.binlog.protocol.TxnMessage)
  private static final com.aliyun.polardbx.binlog.protocol.TxnMessage DEFAULT_INSTANCE;
  static {
    DEFAULT_INSTANCE = new com.aliyun.polardbx.binlog.protocol.TxnMessage();
  }

  public static com.aliyun.polardbx.binlog.protocol.TxnMessage getDefaultInstance() {
    return DEFAULT_INSTANCE;
  }

  private static final com.google.protobuf.Parser<TxnMessage>
      PARSER = new com.google.protobuf.AbstractParser<TxnMessage>() {
    @java.lang.Override
    public TxnMessage parsePartialFrom(
        com.google.protobuf.CodedInputStream input,
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
        throws com.google.protobuf.InvalidProtocolBufferException {
      return new TxnMessage(input, extensionRegistry);
    }
  };

  public static com.google.protobuf.Parser<TxnMessage> parser() {
    return PARSER;
  }

  @java.lang.Override
  public com.google.protobuf.Parser<TxnMessage> getParserForType() {
    return PARSER;
  }

  @java.lang.Override
  public com.aliyun.polardbx.binlog.protocol.TxnMessage getDefaultInstanceForType() {
    return DEFAULT_INSTANCE;
  }

}

